//
// Created by 49647 on 2021/11/15.
//
#include <functional>
#include <utility>
#include <iostream>
#include <memory>
using namespace std;

class Defer {
public:
    explicit Defer(function<void()> f) : m_func(move(f)) {}

    ~Defer() { m_func(); }

private:
    function<void()> m_func;
};

int main() {
    shared_ptr<char> c(new char[5], [](char *p) {delete[] p;});
    int ret = 0;
    Defer defer([&ret]() { printf("ret=%d", ret); });
    ret = 1;
}